const MongoClient = require('mongodb').MongoClient

const url = 'mongodb://localhost:27017'

const dbName = 'koa'

//连接数据库
MongoClient.connect(url, (err, client) => {
  if (err) {
    console.log(err)
    return
  }
  const db = client.db(dbName)
  //增加数据
  db.collection('user').insertOne({
    username: '李四',
    age: 23,
    sex: '男',
    status: '1'
  }).then((result) => {
    console.log('数据增加成功')
    client.close()
  })
})